import { useDayStore } from "@/stores/dayStore";
import DailyInfo from "./parts/DailyInfo";
import Efficiency from "./parts/Efficiency";
import MonthAnalysis from "./parts/MonthAnalysis";
import Promotion from "./parts/Promotion";
import StoreBasicInfo from "./parts/StoreBasicInfo";
import TurnOver from "./parts/MonthTurnover";
import style from "./style.module.scss";
import { useBasicDataStore } from "@/stores/basicDataStore";
import { useEffect } from "react";
import type { StoreInfo } from "@/Interface/StoreInfoInterface";

export default function InfoManagement() {

  const basicData = useBasicDataStore(status => status.basicData) as StoreInfo
  const setDayData = useDayStore(status => status.setDayData)
  const dayData = useDayStore(status => status.dayData)

  useEffect(() => {
    dayData === null ? setDayData(basicData.dailyData[0]) : setDayData(dayData)
  }, [])

  return (
    <>
      <div className={style.main}>
        <StoreBasicInfo />
        <TurnOver />
        <Promotion />
        <DailyInfo />
        <MonthAnalysis />
        <Efficiency />
      </div>
    </>

  )
}